<?php

// 管理员日志

namespace app\console\behavior;

use think\Db;
use think\Request;
use think\Controller;
use think\Session;

class ManagerLog extends Controller
{
    //记录用户行为日志
    public function run(&$params)
    {
        //halt(Request::instance()->controller());
        $MODULE_NAME = strtolower(Request::instance()->module());
        $CONTROLLER_NAME = strtolower(Request::instance()->controller());
        $ACTION_NAME = strtolower(Request::instance()->action());

        $data = [
            'manage_id'     => session('manage_id') ? session('manage_id') : '0',
            'update_ip'   => getIP(),
            'url'      => Request::instance()->module().'/'.Request::instance()->controller().'/'.Request::instance()->action(),
            'update_time' => date('Y-m-d H:i:s', time()),

        ];
       // dump($data);
        $msg = 'act';
        $auth = new \think\Auth();
        $result = $auth->check($MODULE_NAME . '/' . $CONTROLLER_NAME . '/' . $ACTION_NAME, Session::get('manage_id'));
        $array = ['tenmin','refund_service_count','service_count','news','gift_count','goods_count','refund_gift_count','refund_gift_news','refund_service_count','refund_news','refund_goods_count','refund_service_count','refund_goods_count'];
        if(!in_array($ACTION_NAME,$array)){

            $ret = Db::name('managelog1')->insertGetId($data);

        }

        if($result) Db::name('managelog')->insert($data, $msg);

    }
}